//
//  BMKMapManagerHelper.m
//  Etion
//
//  Created by wu jingxing on 13-2-20.
//  Copyright (c) 2013年 GuangZhouXuanWu. All rights reserved.
//

#import "BMKMapManagerHelper.h"

//#define BMKMAP_START_KEY @"6FE9295E1422B3D7474A5322A35197DD611F3E82"

@interface CBMKMapManagerHelperNotication : NSObject<BMKGeneralDelegate>
{
    BOOL m_bStartsuccess;
}

@property(nonatomic,assign) BOOL m_bStartsuccess;

@end

@implementation CBMKMapManagerHelperNotication

@synthesize m_bStartsuccess;

- (void)onGetNetworkState:(int)iError
{
    m_bStartsuccess=NO;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:BMKMAPMANAGERSTARTERROR object:nil];
}

- (void)onGetPermissionState:(int)iError
{
    m_bStartsuccess=NO;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:BMKMAPMANAGERSTARTERROR object:nil];
}

@end

@implementation CBMKMapManagerHelper

static BMKMapManager* s_mapmanager=nil;
static CBMKMapManagerHelperNotication* s_noti;

+(BOOL)start:(NSString*)szBMKkey
{
    if(nil==s_mapmanager)
        s_mapmanager=[BMKMapManager new];
    if(nil==s_noti)
        s_noti=[CBMKMapManagerHelperNotication new];
    BOOL bResult=[s_mapmanager start:szBMKkey generalDelegate:s_noti];
    if(bResult==YES)
        s_noti.m_bStartsuccess=YES;
    else 
        [CBMKMapManagerHelper stop];
    
    return bResult;
}

+(BOOL)stop
{
    BOOL bResult=[s_mapmanager stop];
    [s_noti release_mm];
    s_noti=nil;
    
    return bResult;
}

+(BOOL)isStartSuccess
{
    return s_noti.m_bStartsuccess;
}

@end
